<?php

    // Include domain-specific classes
    require dirname(__FILE__) . DIRECTORY_SEPARATOR . '_include.php';
    
    try {
    
        //----------------------------------------------------------------------
        // Initialise domain objects
        
        // The Master Datagateway will be the base object to amend functionality.
        
        $obj_datagateway = new DataGateway_Master();
        
        // The Legacy Datagateway will encapsulate the code in which to execute
        // after every corresponding method of the base object.
        
        $obj_datagateway_legacy = new DataGateway_Legacy();
    
        
        //----------------------------------------------------------------------
        // Create weaved delegator
        
        // Encapsulate the base object within a Weaved Layer; this will 
        // provide the means to add functionality after a method is invoked.
        
        $obj = new ClassStructure_Weaved_Layers($obj_datagateway);
        
        // Instruct the Weaved Layer to invoke the corresponding method of the
        // Legacy Datagateway after the base object method is invoked.
        
        $obj->__weaveObjectAfter($obj_datagateway_legacy);
        
        
        //----------------------------------------------------------------------
        // Test functionality
        
        $obj->insertPressTitle(array(
            'title_name' => 'Financial Times',
            'title_slug' => 'financial-times',
            'title_type' => 1,
            'categories' => array(1)
        ));
        
        echo "\n\n";
        
        //----------------------------------------------------------------------
        // Expose structure
        
        echo ClassStructure_UtilityFunctions::getObjectSignature($obj);
        echo "\n";
        echo ClassStructure_UtilityFunctions::getAdviceSignature($obj, 'insertPressTitle');
        
        
    } catch (Exception $obj_exception) {
        print_r($obj_exception);
    }
